﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace PrismRegion.Navigation.ViewModels.Pages
{
    public class ViewAViewModel : INavigationAware,IRegionMemberLifetime,IConfirmNavigationRequest
    {
        public string Title { get; set; } = "ViewA";
        public ViewAViewModel(IRegionNavigationService region)
        {
            
        }
        public bool KeepAlive => true;

        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
        {
            //从当前页面是否打开另外一个页面
            if (MessageBox.Show("是否打开？", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                continuationCallback?.Invoke(true);
            }
            else {
                continuationCallback?.Invoke(false);
            }
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            //是否允许重复导航进来
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            //从当前View导航出去时候触发
            navigationContext.Parameters.Add("abcd", "abcdabcd");
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            //打开当前View的时候触发
            string aaaa = navigationContext.Parameters.GetValue<string>("abcd");
        }
    }
}
